package com.chixing.day07.ProtoType;

/***
 * 浅克隆:类具有一些基础属性(基本数据类型 + toString === 值传递)
 *       ,他的克隆对象:
 *                    (1) new 当前对象
 *                    (2)克隆对象的属性与原始属性一致
 *
 * 深克隆:类具有一些基础属性还有关联对象,他的克隆对象:
 *              (1) new 当前对象
 *              (2) 克隆对象的属性与原始对象属性一致,原始对象的关联对象也要克隆一份
 */
public class ProductTest {
    public static void main(String[] args) throws CloneNotSupportedException {
        Product pro = new Product();
        pro.setProId(101);
        pro.setProName("康师傅");
        pro.setProPrice(1.9f);

        Object cloneObj = pro.clone();
        System.out.println("原始对象: " + pro);
        System.out.println("克隆对象: " + cloneObj);
        ;

        System.out.println("===================");

        Company com = new Company();
        com.setCompanyId(101);
        com.setCompanyName("Google");
        com.setCompanyType("System");
        com.setCompanyAddress("USA");
        com.setCompanyTelno(15151515151555l);

        Company comClone = com.clone();
        System.out.println("原始对象: " + com);
        System.out.println("克隆对象: " + comClone);
        ;

        System.out.println("===================");

        Job job = new Job();
        job.setJobId(101);
        job.setCompany(com);
        job.setJobName("java工程师");
        job.setJobMinSalary(2000);
        job.setJobMaxSalary(100000);
        job.setJobDegree("本科");
        job.setJobCity("USA");


        Job jobClone = job.clone();
        System.out.println("原始对象: " + job);
        System.out.println("克隆对象: " + jobClone);
        ;


















             /*  //product 克隆对象
        //浅克隆
        Product proClone = new Product();
        proClone.setProId(pro.getProId());
        proClone.setProName(pro.getProName());
        proClone.setProPrice(pro.getProPrice());*/

    }
}
